// 定义module

import {Connection} from "mongoose";
import {MongooseSchema} from './schemas/mongoose.schema'

export const mongooseProviders = [
    {
        // 自己定义一个到时候在service.ts中注入
        provide: 'MongooseModel',
        // 使用Schema 文件
        useFactory: (connection: Connection) => {
            return connection.model('mongoose', MongooseSchema)
        },
        // DbConnectionToken是database.providers.ts里面的key
        inject: ['DATABASE_CONNECTION']
    }
]